import requests
from pyquery import PyQuery as pq
from lxml import html, etree

query = pq(filename='../后端反爬/templates/index.html', encoding='utf8')
# print(query, type(query))
title = query('title')
# print(title.text())
links = query(".container ul li a")


# print(dir(links))
def parse_link(index, item):
    # print(index, item.text, item.attrib.get("href"))
    # link_query = pq(item)
    # print(link_query.text(), link_query.attr("href"))
    print(item.xpath('./text()')[0], item.xpath('./@href')[0])


links.each(parse_link)
